const configure ={
  state:{
    HOST: 'http://localhost:8888', //后台访问地址目录
    activeName:'' ,//当前选中的菜单名
    loginIn: {
      status:!!((JSON.parse(localStorage.getItem('loginIn')) || {}).status)
  },//用户是否登录
    isActive:false,//当前歌曲是否已收藏
    sConsumer:JSON.parse(localStorage.getItem('sConsumer')) || {}
  },
  getters : {
      activeName:state =>{
        let activeName = state.activeName
        if (!activeName){
          activeName = JSON.parse(localStorage.getItem('activeName'))
        }
        return activeName
      },
    loginIn:state =>{
      let loginIn = state.loginIn
      if (!loginIn){
        loginIn = JSON.parse(localStorage.getItem('loginIn'))
      }
      return loginIn
    },
    isActive:state =>{
      let isActive = state.isActive
      if (!isActive){
        isActive = JSON.parse(localStorage.getItem('isActive'))
      }
      return isActive
    },

  },
  mutations:{
    setActiveName:(state,activeName)=>{
        state.activeName = activeName
        localStorage.setItem('activeName',JSON.stringify(activeName))
    },
    setLoginIn:(state,isLogin)=>{
      state.loginIn.status = isLogin;
      localStorage.setItem('loginIn',JSON.stringify({status:isLogin}))
    },
    setIsActive:(state,isActive)=>{
      state.isActive = isActive
      localStorage.setItem('isActive',JSON.stringify(isActive))
    },
    setSConsumer(state,sConsumerInfo){
      state.sConsumer = sConsumerInfo;
      localStorage.setItem("sConsumer",JSON.stringify(sConsumerInfo))//存储用户信息到游览器
    },
    setLogOut(){
      this.commit('setLoginIn',false)
     this.commit('setSConsumer',{})
    }
  }
}
export default configure

